import React from 'react';
import {Link, useNavigate} from "react-router-dom";

function AppHeader(props) {

  const navigate = useNavigate();

  function navigateTo(path) {
    navigate(path);
  }

  return (
      <div className='header'>
        <span>header</span>
        <div className='nav'>
          <Link to='/home'>首页</Link>
          <Link to='/about'>关于</Link>
          <Link to='/login'>登录</Link>
          <button onClick={ e => navigateTo('/category') }>分类</button>
          <span onClick={ e => navigateTo('/order') }>订单</span>
          <Link to='/detail'>详情</Link>
          <Link to='/user?name=lyq&age=18'>用户</Link>
        </div>
      </div>
  );
}

export default AppHeader;